package com.blaze.framework.core.util.domain;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class HttpErrorMessage {
    /**
     * 状态
     */
    private int status;
    /**
     * 异常信息
     */
    private String message;
    /**
     * 时间戳
     */
    private Long timestamp;
    /**
     * 堆栈信息
     */
    @Schema(description = "堆栈信息")
    private String stacktrace;

    public HttpErrorMessage() {

    }

    public HttpErrorMessage(int status, String message, Long timestamp,
                            String stacktrace) {
        this.status = status;
        this.message = message;
        this.timestamp = timestamp;
        this.stacktrace = stacktrace;
    }

    public static HttpErrorMessage of(int status, String message) {
        HttpErrorMessage httpErrorMessage = new HttpErrorMessage();
        httpErrorMessage.setStatus(status);
        httpErrorMessage.setMessage(message);
        httpErrorMessage.setTimestamp(System.currentTimeMillis());
        return httpErrorMessage;
    }

    public static HttpErrorMessage of(int status, String message, String stacktrace) {
        HttpErrorMessage httpErrorMessage = new HttpErrorMessage();
        httpErrorMessage.setStatus(status);
        httpErrorMessage.setMessage(message);
        httpErrorMessage.setStacktrace(stacktrace);
        httpErrorMessage.setTimestamp(System.currentTimeMillis());
        return httpErrorMessage;
    }
}